package com.qiu.wxapi.service;

import com.qiu.wxapi.mapper.UserMapper;
import com.qiu.wxapi.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


@Service
public class UserService {
    @Autowired
    private UserMapper userMapper;

    /**
     * 普通登录
     * @param user
     * @return
     */
    public User doLogin(User user) {
        User user1 = this.userMapper.selectOne(user);
        return user1;
    }

    /**
     * 注册
     * @param user
     * @return
     */
    public Boolean register(User user) {
        User user1 = new User();
        user1.setUsername(user.getUsername());
        user1.setClassRoom(user.getClassRoom());
        user1.setTel(user.getTel());
        this.userMapper.selectOne(user1);
        if (this.userMapper.selectOne(user1)!=null){
            return false;
        }
        user.setRole("1");
        this.userMapper.insert(user);
        return true;

    }
}
